package com.cai.oamanager.service.impl;

import com.cai.oamanager.dao.DepartDao;
import com.cai.oamanager.entity.Depart;
import com.cai.oamanager.entity.Domain;
import com.cai.oamanager.service.DepartService;
import com.cai.oamanager.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version 1.0
 * @author：蔡松坡
 * @date：2021/1/16 18 : 08
 * @package：com.cai.oamanager.service.impl
 */
@Service
public class DepartServiceImpl implements DepartService {

    @Autowired
    private DepartDao departDao;

    @Autowired
    private StudentService studentService;
    @Override
    public List<Depart> getAllDepart(Integer start,Integer size) {
        List<Depart> allDepart = departDao.getAllDepart(start, size);
        for (Depart depart : allDepart) {
            Integer count = studentService.getCountByDeid(depart.getId());
            depart.setNum(count);
        }
        return allDepart;
    }

    @Override
    public Depart getDepart(Integer id) {
        return departDao.getDepart(id);
    }

    @Override
    public void deleteDepart(Integer id) {
        departDao.deleteDepart(id);
    }

    @Override
    public void updateDepart(Depart depart) {
        departDao.updateDepart(depart);
    }

    @Override
    public Integer getCountDepart() {
        return departDao.getCountDepart();
    }

    @Override
    public List<Domain> getAllDomain() {
        return departDao.getAllDomain();
    }
}
